<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="../../../../header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body style="align: center;">
	<div style="margin-top: 10px; margin-left: 30px;">
		<form id="manage-form" action="">
			<div style="margin-left: 10px;">
			
				<label for="jobcode">系统模块:</label> 
				<select type="text" style="width: 200px; height: 28px;" class="ui-input" name="systemcode" id="systemcode">
					<s:forEach items="${sessionScope.systemList}" var="system">
						<option value="${system.systemname }">${system.systemname }</option>
					</s:forEach>
				</select>
				<br><br>
				
				<label for="jobcode">权限name:</label> 
				<input type="text" style="width: 120px; height: 28px;" class="ui-input" name="permissionname" id="permissionname">
				<br><br>
				
				<label for="jobcode">实体(表)名字:</label> 
				<select name="entitycode" id="entitycode">
					<option value="gy_action">操作表</option>
					<option value="gy_company">公司表</option>
					<option value="gy_department">部门表</option>
					<option value="gy_permission">权限表</option>
					<option value="gy_role">角色表</option>
					<option value="gy_role_permission">角色权限表</option>
					<option value="gy_system">系统设置表</option>
					<option value="gy_user">用户表</option>
					<option value="gy_user_role">用户角色表</option>
					<option value="rs_check">审核表</option>
					<option value="rs_kaoqin">考勤表</option>
					<option value="rs_kaoqinmonth">考勤月结表</option>
					<option value="rs_qingjiaapply">请假申请表表</option>
				</select>
				<br><br>
				
				<label for="jobcode">实体说明:</label> 
				<input type="text" style="width: 120px; height: 28px;" class="ui-input" name="entityname" id="entityname">
				<br><br>
				
				<label for="jobcode">操作名称:</label> 
				<select type="text" style="width: 200px; height: 28px;" class="ui-input" name="actioncode" id="actioncode">
					<s:forEach items="${sessionScope.actionList}" var="action">
						<option value="${action.actionname }">${action.actionname }</option>
					</s:forEach>
				</select>
				<br><br>
			</div>
		</form>
	</div>

	<script type="text/javascript">
var api=frameElement.api;
var operate=api.data.operate;
var rowid=api.data.rowid;
var rowdata=api.data.rowdata;
var CallBack=api.data.callback;
$(function(){
	initPopBtns();
	if(operate=="edit"){
		$("#systemcode").val(rowdata.systemcode);
		$("#permissioncode").val(rowdata.permissioncode);
		$("#permissionname").val(rowdata.permissionname);
		$("#entitycode").val(rowdata.entitycode);
		$("#entityname").val(rowdata.entityname);
		$("#actioncode").val(rowdata.actioncode);
	}
})
function initPopBtns() {
	var btnname = "add" == operate ? ["保存", "关闭"] : ["确定", "取消"];
	api.button({
		id: "confirm",
		name: btnname[0],
		focus: true,
		callback: function(e) {
			var systemCode=$("#systemcode").val();
			var permissionCode=$("#permissioncode").val();
			var permissionName=$("#permissionname").val();
			var entityCode=$("#entitycode").val();
			var entityName=$("#entityname").val();
			var actionCode=$("#actioncode").val();
			if(operate=="add"){
				$.ajax({
					url : 'permission/edit',
					type : 'POST',
					dataType : "json",
					data: {
						"systemcode":systemCode,
						"permissioncode":permissionCode,
						"permissionname":permissionName,
						"entitycode":entityCode,
						"entityname":entityName,
						"actioncode":actionCode,
						"oper":"add"
					},
					async : false,
					success : function(data) {
						if(data.status==200){
							parent.Public.tips({
								content: "添加成功"
							})
							CallBack();
						}else{
							parent.Public.tips({
								type:1,
								content: "添加失败:"+data.message
							})
						}
					}
				});
			}else{
				$.ajax({
					url:encodeURI("permission/edit"),
					type:"POST",
					data:{
						"id":rowid,
						"systemcode":systemCode,
						"permissioncode":permissionCode,
						"permissionname":permissionName,
						"entitycode":entityCode,
						"entityname":entityName,
						"actioncode":actionCode,
						"oper":"edit"
					},
					async : false,//同步,坑爹啊。。
					success:function(data){
						if(data.status==200){
							parent.Public.tips({
								content: "修改成功"
							})
							CallBack();
						}else{
							parent.Public.tips({
								type:1,
								content: "修改失败:"+data.message
							})
						}		
					}
				});
			}
		}
	}, {
		id: "cancel",
		name: btnname[1]
	})
}



</script>
</body>
</html>